package yh;

/**
 * 二维数组的遍历
 */
public class ArrayDemo10 {
    public static void main(String[] args) {
        //1.矩形
        int[][] arr1=new int[4][3];
        //2.循环赋值
        for (int i = 0; i <arr1.length ; i++) {
            for(int j=0;j<arr1[i].length;j++){
                arr1[i][j]=1;
            }
        }
        //3.循环遍历
        for (int i = 0; i <arr1[i].length; i++) {
            for(int j=0;j<arr1[i].length;j++){
                System.out.print(arr1[i][j]+"\t");
            }
            System.out.println();
        }
        System.out.println(arr1.length);
        System.out.println("=========");

        //2.直角三角形练习
        String[][] arr2=new String[4][];
        //3.循环赋值
        for (int i = 0; i < arr2.length; i++) {
            //4.定义一维数组
            arr2[i]=new String[i+1];
            for(int j=0;j<arr2[i].length;j++){
                arr2[i][j]="*";
            }
        }
        //4.打印二维数组
        for (int i = 0; i <arr2.length ; i++) {
            for(int j=0;j<arr2[i].length;j++){
                System.out.print(arr2[i][j]+"\t");
            }
            System.out.println();
        }
    }
}
